package fyf.com.carddesign.MyUtl;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import fyf.com.carddesign.Dao.DaoMaster;
import fyf.com.carddesign.Dao.DaoSession;

/**
 * 系统服务
 * Created by Admin on 2017/10/20.
 */

public class MyApplication extends Application {
    private static DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        createdDataBase();
    }

    //创建数据库
    private void createdDataBase() {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this,
                "card.db", null);
        //获取可写数据库
        SQLiteDatabase db = helper.getWritableDatabase();
        //获取数据库对象
        DaoMaster daoMaster = new DaoMaster(db);
        //获取Dao对象管理着
        daoSession = daoMaster.newSession();
    }

    //获取Dao对相管理者
    public static DaoSession getDaoInstant() {
        return daoSession;
    }
}
